package com.wayne.controller;

import com.wayne.domain.User;
import com.wayne.service.IUserApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
public class TestController {
    @Autowired
    private IUserApi userApi;

    @GetMapping
    public void test() {
//        Flux<User> user = userApi.getAllUser();

//        userApi.getAllUser();
        Mono<User> user = userApi.getUserById("61640e9bb187071457035e");
//        Mono<Void> user = userApi.deleteUserById("2222");
//        Mono<User> user = userApi.addUser(Mono.just(User.builder().name("admin").age(22).build()));
        user.subscribe(u -> {
            System.out.println("找到用户信息：" + u);
        }, e -> {
            System.out.println("找不到用户：" + e.getMessage());
        });
    }
}
